﻿<Canvas x:Class="Chem4Word.UI.TwoD.ChemCanvas"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:Controls="clr-namespace:Chem4Word.UI"
        xmlns:Converters="clr-namespace:Chem4Word.UI.Converters"
        xmlns:Commands="clr-namespace:Chem4Word.UI.Commands"
        x:Name="theCanvas"
        FocusManager.FocusedElement="{Binding RelativeSource={x:Static RelativeSource.Self}, Mode=OneTime}"
        VerticalAlignment="Stretch"
        HorizontalAlignment="Stretch">
    <Canvas.Resources>
        <Converters:DrawingModeToBooleanConverter x:Key="DrawingModeToBooleanConverter" />
    </Canvas.Resources>
    <!--<Canvas.CommandBindings>
        <CommandBinding Command="{x:Static Controls:ChemCommands.RotateSelection}" Executed="Rotate_Executed" CanExecute="RotateSelection_CanExecute" />
        <CommandBinding Command="{x:Static Controls:ChemCommands.DeleteSelection}" Executed="DeleteSelection_Executed" CanExecute="DeleteSelection_CanExecute" />
        <CommandBinding Command="{x:Static Controls:ChemCommands.FlipHorizontal}" Executed="FlipHorizontal_Executed" CanExecute="FlipHorizontal_CanExecute"/>
        <CommandBinding Command="{x:Static Controls:ChemCommands.FlipVertical}" Executed="FlipVertical_Executed" CanExecute="FlipVertical_CanExecute"/>
        <CommandBinding Command="{x:Static Controls:ChemCommands.AddElectron}" Executed="AddElectron_Executed" CanExecute="AddRemoveElectron_CanExecute" />
        <CommandBinding Command="{x:Static Controls:ChemCommands.RemoveElectron}" Executed="RemoveElectron_Executed" CanExecute="AddRemoveElectron_CanExecute" />
        <CommandBinding Command="{x:Static Controls:ChemCommands.AddLabel}" Executed="AddLabel_Executed" CanExecute="AddLabel_CanExecute" />
        <CommandBinding Command="{x:Static Controls:ChemCommands.RemoveLabel}" Executed="RemoveLabel_Executed" CanExecute="RemoveLabel_CanExecute" />
        <CommandBinding Command="{x:Static Controls:ChemCommands.FlipSelection}" Executed="FlipSelection_Executed" CanExecute="FlipSelection_CanExecute" />
        <CommandBinding Command="{x:Static Controls:ChemCommands.RemoveIsotopeNumber}" Executed="RemoveIsotope_Executed" CanExecute="RemoveIsotope_CanExecute" />
        <CommandBinding Command="{x:Static Controls:ChemCommands.SetCharge}" Executed="SetCharge_Executed" CanExecute="SetCharge_CanExecute" />
        <CommandBinding Command="{x:Static Controls:ChemCommands.RemoveCharge}" Executed="RemoveCharge_Executed" CanExecute="RemoveCharge_CanExecute" />
        <CommandBinding Command="{x:Static Controls:ChemCommands.AddProton}" Executed="AddProton_Executed" CanExecute="AddProton_CanExecute" />
        <CommandBinding Command="{x:Static Controls:ChemCommands.RemoveProton}" Executed="RemoveProton_Executed" CanExecute="RemoveProton_CanExecute" />
        <CommandBinding Command="{x:Static Controls:ChemCommands.AddHydrogenDot}" Executed="AddHydrogenDot_Executed" CanExecute="AddHydrogenDot_CanExecute" />
        <CommandBinding Command="{x:Static Controls:ChemCommands.RemoveHydrogenDot}" Executed="RemoveHydrogenDot_Executed" CanExecute="RemoveHydrogenDot_CanExecute" />
        <CommandBinding Command="{x:Static ApplicationCommands.SelectAll}" Executed="SelectAll_Executed"/>
        <CommandBinding Command="{x:Static ApplicationCommands.Undo}" Executed="Undo_Executed" CanExecute="Undo_CanExecute" />
        <CommandBinding Command="{x:Static ApplicationCommands.Redo}" Executed="Redo_Executed" CanExecute="Redo_CanExecute" />        
    </Canvas.CommandBindings>-->
    <Canvas.InputBindings>
        <KeyBinding Gesture="Delete"
                    Command="{x:Static Commands:ChemCommands.DeleteSelection}" />
        <KeyBinding Key="z"
                    Modifiers="Ctrl"
                    Command="{x:Static ApplicationCommands.Undo}" />
        <KeyBinding Key="y"
                    Modifiers="Ctrl"
                    Command="{x:Static ApplicationCommands.Redo}" />
        <KeyBinding Key="a"
                    Modifiers="Ctrl"
                    Command="{x:Static ApplicationCommands.SelectAll}" />
    </Canvas.InputBindings>
    <Canvas.ContextMenu>
        <ContextMenu>
            <MenuItem x:Name="menuItemAtomSelect"
                      IsCheckable="True"
                      IsChecked="{Binding Mode=TwoWay, Path=PlacementTarget.DrawingMode, RelativeSource={RelativeSource AncestorType={x:Type ContextMenu}}, Converter={StaticResource DrawingModeToBooleanConverter}, ConverterParameter=Atom}"
                      Header="Atom Mode" />
            <MenuItem x:Name="menuItemBondSelect"
                      IsCheckable="True"
                      IsChecked="{Binding Mode=TwoWay, Path=PlacementTarget.DrawingMode, RelativeSource={RelativeSource AncestorType={x:Type ContextMenu}}, Converter={StaticResource DrawingModeToBooleanConverter}, ConverterParameter=Bond}"
                      Header="Bond Mode" />
            <MenuItem CommandTarget="{Binding Path=PlacementTarget, RelativeSource={RelativeSource AncestorType={x:Type ContextMenu}}}"
                      Command="{x:Static ApplicationCommands.SelectAll}"
                      Header="Select All" />
        </ContextMenu>
    </Canvas.ContextMenu>
</Canvas>